#!/bin/bash
NAME="cli.php" 
PID=`ps -ef | grep "$NAME" | grep -v "grep" | awk '{print $2}'`
if [ -z "$PID" ];then
    (php $NAME &)
    echo "start $NAME"
else
    echo $PID
    for pid in $PID
        do
        kill $pid
        echo "killed $pid"
    done
    (php $NAME &)
    echo "restart $NAME"
fi